package com.qumitech.visualnovel.controller.rest;


import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.service.pay.RechargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/recharge")
public class RechargeStatisticsController {

    @Autowired
    private RechargeService rechargeService;

    @GetMapping("/daily_statistics")
    public BaseRsp getRechargeDailyStatistics(@RequestParam(value = "start_time", required = false) String startTime,
                                              @RequestParam(value = "end_time", required = false) String endTime,
                                              @RequestParam(value = "geo_name", required = false) String geoName,
                                              @RequestParam(value = "channel", required = false) String channel,
                                              @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset,
                                              @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) {
        return new BaseRsp(ResultEnum.SUCCESS, rechargeService.getRechargeDailyStatistics(
                startTime, endTime, geoName, channel, offset, limit));
    }

    @GetMapping("/transfer_statistics")
    public BaseRsp getRechargeTransferStatistics(@RequestParam(value = "start_time", required = false) String startTime,
                                                 @RequestParam(value = "end_time", required = false) String endTime,
                                                 @RequestParam(value = "book_ids", required = false) List<Integer> bookIds,
                                                 @RequestParam(value = "book_title", required = false) String bookTitle,
                                                 @RequestParam(value = "geo_name", required = false) String geoName,
                                                 @RequestParam(value = "channel", required = false) String channel,
                                                 @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset,
                                                 @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) {
        return new BaseRsp(ResultEnum.SUCCESS, rechargeService.getRechargeTransferStatistics(
                startTime, endTime, bookIds, bookTitle, geoName, channel, offset, limit));
    }

}
